﻿<?php
defined('BASEPATH') or die ('No direct script access allowed');

class Users_model extends Model{
    protected $_data=null;
    protected $_id=null;
    
    function Users_model(){
        parent::Model();
    }
    
    function get_data(){
        if(!$this->_data){
        	if($this->_id){
        	   $query="select * from doi_user where id=".intval($this->_id);
        	}else{
        		$query="select * from doi_user";
        	}   
        	$this->_data=$this->db->query($query);
        }
        return $this->_data;
    }
    
    function set_id($id){
        $this->id=$id;
    }
    
    function format_to_object(){
    	if(!$this->_data){
            return $this->_data->result();
    	}else{
    		return null;
    	}
    }
    
    function format_to_array(){
    	if(!$this->_data){
            return $this->_data->result_array();
    	}else{
    		return null;
    	}
    }
    
    function format_to_user_model(){
        if(!$this->_data){
        	return $this->load->model('user_model','',$this->_data);
        }else{
        	return null;
        }
    }
}